package com.example.test003.controller;

import com.example.test003.service.WeatherBaiKeService;
import com.example.test003.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.annotation.QueryAnnotation;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/weather")
public class WeatherBaiKeController {
    @Autowired
    private WeatherBaiKeService weatherBaiKeService;

    @GetMapping
    public ResponseResult getQxyy1(@RequestParam(value = "first") String first,
                                   @RequestParam(value = "second") String second,
                                   @RequestParam("id") Integer id) {
        // 气象百科
        if ("qxbk".equals(first)) {
            if ("qxyy".equals(second))
                return weatherBaiKeService.getQxyy(id);
            if ("24jq".equals(second))
                return weatherBaiKeService.get24Jq(id);
            if ("qxzs".equals(second))
                return weatherBaiKeService.getQxzs(id);
            if ("qxsy".equals(second))
                return weatherBaiKeService.getQxsy(id);
            if ("qxyb".equals(second))
                return weatherBaiKeService.getQxyb(id);
            if ("qt".equals(second))
                return weatherBaiKeService.getQt(id);
            else
                return ResponseResult.errorResult(401, "数据获取有误！");
            // 气象灾害
        } else if ("qxzh".equals(first)) {
            if ("qxyj".equals(second))
                return weatherBaiKeService.getQxyj(id);
            if ("qhbh".equals(second))
                return weatherBaiKeService.getQhbh(id);
            if ("yjbs".equals(second))
                return weatherBaiKeService.getYjbs(id);
            if ("yjzs".equals(second))
                return weatherBaiKeService.getYjzs(id);
            else
                return ResponseResult.errorResult(401, "数据获取有误！");
        }
        return ResponseResult.errorResult(401, "数据获取有误！");
    }
}